package Year21_Month11.day1117;

public class Sort{
    public static void swap(int[] arr,int left,int right){
        int tmp = arr[left];
        arr[left] = arr[right];
        arr[right] = tmp;
    }
    public static void print(int[] arr){
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }


    public static void BubbleSort(int[] arr){
        for(int i = arr.length;i > 0;i--){
            for(int j = 1;j < i;j++){
                if(arr[j] < arr[j - 1]){
                    swap(arr,j,j - 1);
                }
            }
        }
    }
    public static void main(String[] args) {
        int[] arr = {4,2,8,6,9,1,3,5,0,7};
        BubbleSort(arr);
        print(arr);
    }
}
